package com.xiyu.service.controller.admin.market;
import com.xiyu.service.vo.market.marketSetting.MarketSettingUpdateReplyInput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingCreateReplyInput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingSingleGetReplyOutput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingReplyListOutput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingReplyListInput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingUpdateSenderInput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingCreateSenderInput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingSingleGetSenderOutput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingSenderListOutput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingSenderListInput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingUpdateDomainInput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingCreateDomainInput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingSingleGetDomainOutput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingDomainListOutput;
import com.xiyu.service.vo.market.marketSetting.MarketSettingDomainListInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.*;

import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.market.MarketSettingService;

@Tag(name = "营销设置")
@RestController
@RequestMapping("/market/market-setting")
@Validated
public class MarketSettingController {

    @Resource
    private MarketSettingService marketSettingService;

    @GetMapping("/domain-list")
    @Operation(summary = "查询发信域名")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:list')")
    public CommonResult<List<MarketSettingDomainListOutput>> domainList(@Valid MarketSettingDomainListInput inputVO) {
        return success(marketSettingService.domainList(inputVO));
    }

    @GetMapping("/single-get-domain")
    @Operation(summary = "获取单个发信域名")
    @Parameter(name = "id", description = "发信域名主键ID", example = "")
    public CommonResult<MarketSettingSingleGetDomainOutput> singleGetDomain(@RequestParam("id") Long id) {
        return success(marketSettingService.singleGetDomain(id));
    }

    @PostMapping("/create-domain")
    @Operation(summary = "新增发信域名")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:domainCreate')")
    public CommonResult<Long> createDomain(@Valid @RequestBody MarketSettingCreateDomainInput inputVO) {
        return success(marketSettingService.createDomain(inputVO));
    }

    @PutMapping("/update-domain")
    @Operation(summary = "更新发信域名")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:domainUpdate')")
    public CommonResult<Boolean> updateDomain(@Valid @RequestBody MarketSettingUpdateDomainInput inputVO) {
        return success(marketSettingService.updateDomain(inputVO));
    }

    @DeleteMapping("/deleted-domain")
    @Operation(summary = "删除发信域名")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:domainDeleted')")
    @Parameter(name = "id", description = "发信域名主键ID", example = "")
    public CommonResult<Boolean> deletedDomain(@RequestParam("id") Long id) {
        return success(marketSettingService.deletedDomain(id));
    }

    @GetMapping("/sender-list")
    @Operation(summary = "查询发件人")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:list')")
    public CommonResult<List<MarketSettingSenderListOutput>> senderList(@Valid MarketSettingSenderListInput inputVO) {
        return success(marketSettingService.senderList(inputVO));
    }

    @GetMapping("/single-get-sender")
    @Operation(summary = "获取单个发件人")
    @Parameter(name = "id", description = "营销发件人设置主键ID", example = "")
    public CommonResult<MarketSettingSingleGetSenderOutput> singleGetSender(@RequestParam("id") Long id) {
        return success(marketSettingService.singleGetSender(id));
    }

    @PostMapping("/create-sender")
    @Operation(summary = "新增发件人")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:senderCreate')")
    public CommonResult<Long> createSender(@Valid @RequestBody MarketSettingCreateSenderInput inputVO) {
        return success(marketSettingService.createSender(inputVO));
    }

    @PutMapping("/update-sender")
    @Operation(summary = "更新发件人")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:senderUpdate')")
    public CommonResult<Boolean> updateSender(@Valid @RequestBody MarketSettingUpdateSenderInput inputVO) {
        return success(marketSettingService.updateSender(inputVO));
    }

    @DeleteMapping("/deleted-sender")
    @Operation(summary = "删除发件人")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:senderDeleted')")
    @Parameter(name = "id", description = "营销发件人设置主键ID", example = "")
    public CommonResult<Boolean> deletedSender(@RequestParam("id") Long id) {
        return success(marketSettingService.deletedSender(id));
    }

    @GetMapping("/reply-list")
    @Operation(summary = "查询回复人")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:list')")
    public CommonResult<List<MarketSettingReplyListOutput>> replyList(@Valid MarketSettingReplyListInput inputVO) {
        return success(marketSettingService.replyList(inputVO));
    }

    @GetMapping("/single-get-reply")
    @Operation(summary = "获取单个回复人")
    @Parameter(name = "id", description = "营销回复人设置主键ID", example = "")
    public CommonResult<MarketSettingSingleGetReplyOutput> singleGetReply(@RequestParam("id") Long id) {
        return success(marketSettingService.singleGetReply(id));
    }

    @PostMapping("/create-reply")
    @Operation(summary = "新增回复人")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:replyCreate')")
    public CommonResult<Long> createReply(@Valid @RequestBody MarketSettingCreateReplyInput inputVO) {
        return success(marketSettingService.createReply(inputVO));
    }

    @PutMapping("/update-reply")
    @Operation(summary = "更新回复人")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:replyUpdate')")
    public CommonResult<Boolean> updateReply(@Valid @RequestBody MarketSettingUpdateReplyInput inputVO) {
        return success(marketSettingService.updateReply(inputVO));
    }

    @DeleteMapping("/deleted-reply")
    @Operation(summary = "删除回复人")
    @PreAuthorize("@ss.hasPermission('market:marketSetting:replyDeleted')")
    @Parameter(name = "id", description = "营销回复人设置主键ID", example = "")
    public CommonResult<Boolean> deletedReply(@RequestParam("id") Long id) {
        return success(marketSettingService.deletedReply(id));
    }

}
